package com.jingdianjichi.subject.domain.Handler.subject;

import com.jingdianjichi.subject.common.enums.IsDeletedCodeEnum;
import com.jingdianjichi.subject.common.enums.SubjectInfoTypeCodeEnum;
import com.jingdianjichi.subject.domain.entity.SubjectInfoBo;
import com.jingdianjichi.subject.infra.basic.entity.SubjectBrief;
import com.jingdianjichi.subject.infra.basic.service.SubjectBriefService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class BriefTypeHandler implements SubjectTypeHandler{
    @Resource
    private SubjectBriefService subjectBriefService;

    @Override
    public SubjectInfoTypeCodeEnum getHandlerType() {
        return SubjectInfoTypeCodeEnum.BRIEF;
    }



    @Override
    public void add(SubjectInfoBo subjectInfoBO) {
        SubjectBrief subjectBrief = new SubjectBrief();
        BeanUtils.copyProperties(subjectInfoBO,subjectBrief);


        subjectBrief.setSubjectId(subjectInfoBO.getId().intValue());
        subjectBrief.setIsDeleted(IsDeletedCodeEnum.UN_DELETED.getCode());
        subjectBriefService.insert(subjectBrief);
    }

//    @Override
//    public SubjectOptionBO query(int subjectId) {
//        SubjectBrief subjectBrief = new SubjectBrief();
//        subjectBrief.setSubjectId(subjectId);
//        SubjectBrief result = subjectBriefService.queryByCondition(subjectBrief);
//        SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
//        subjectOptionBO.setSubjectAnswer(result.getSubjectAnswer());
//        return subjectOptionBO;
//    }

}
